<template>
    <st-uni-loadmore ref="loadmoreref">
        <uni-list :border="true">
            <uni-list-chat v-for=" item in listData" :avatar-circle="true" :title="item.nickname" :key="item.id"
                           :avatar="item.avatar" :note="item.gender" :time="item.createAt"
                           @click="$utils.n.ngt('/pages/detail/detail?userId=' + item.invitedUserId)"
                           clickable/>
        </uni-list>
    </st-uni-loadmore>
</template>

<script>
    import StUniLoadmore from "../../components/StUniLoadmore";
    export default {
        components: {StUniLoadmore},
        data() {
            return {
                searchForm: {
                    orderBy: 'createAt-0',
                    userId: this.$store.state.userInfo.id
                },
                listData: []
            };
        },
        onPullDownRefresh(){
            this.loadData(true)
        },
        onReachBottom() {
            this.loadData(false)
        },
        onLoad(){

        },
        onReady(){
            this.loadData(true)
        },
        methods: {
            loadData:function(pullDownRefresh){
                if(!this.$refs.loadmoreref){
                    return
                }
                uni.showLoading({
                    title: '加载中'
                })
                this.$refs.loadmoreref.loadData('/user-invitation/getPage',{
                    pullDownRefresh:!!pullDownRefresh,
                    data: this.searchForm}).then(res=> {
                    let content = res.data.records
                    if(pullDownRefresh){
                        this.listData = content
                    }else{
                        this.listData = this.listData.concat(content);
                    }
                }).finally(() => {
                    uni.hideLoading();
                })
            }
        }
    }
</script>

<style>

</style>
